package com.Thread02.demo06;

import java.util.concurrent.Semaphore;

public class MyRnnuer02 implements Runnable {
    private Semaphore sp = new Semaphore(2);

    @Override
    public void run() {
        try {
            sp.acquire();
            System.out.println("已经获得了通行证");
            Thread.sleep(1000);
            System.out.println("归还了通行证");
            sp.release();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
